/*
Realistic Unit Modification v4.0 Dialog 
v4.0.0.1 [ALPHA]
Concept & Development by Draper & Raps | [VRC]
*/

private ["_payload","_arry","_plane","_callsign","_home","_airport","_egress","_ingress","_class","_spwn","_mkrname","_asloc","_mkrname2","_asloc2","_pilot","_plane","_grp","_wp"];

/* variables defined */
_payload = _this select 0;
_arry = _this select 1;
_callsign = _arry select 1;

/* check to make sure the plane is not defined already to be on station */
if (RUM_FXD_NonSpawn) then {
	_plane = _arry select 0;
} else {
	_plane = _arry select (count _arry - 1);
};

/* removes weapons from the plane */
removeAllweapons _plane;

/* defines payload and mission type */
if ("cas" in _array) then { 
	_plane call RUM_FXD_weaponLoad;
};

/* defines markers for map selection */
_mkrname = format ["%1station",_plane];
_asloc = createMarker [_mkrname, getPos _plane];
_asloc setMarkerShape "ELLIPSE";
_mkrname setMarkerBrush "BORDER";
_mkrname setMarkerSize [1200,1200];
_mkrname setMarkerColor "ColorGreen";
_mkrname setMarkerText _callsign;
_mkrname2 = format ["%1station2",_plane];
_asloc2 = createMarker [_mkrname2, getmarkerpos _mkrname];
_asloc2 setMarkerShape "ICON";
_mkrname2 setMarkerSize [1,1];
_mkrname2 setMarkerType "mil_Dot";
_mkrname2 setMarkerColor "ColorGreen";
_mkrname2 setMarkerText _callsign;

/* defines the pilot of the plane and group */
_pilot = driver _plane;
_grp = group _pilot;

/* sets the altitude to be stationed at */
_plane flyInheight RUM_FXD_flyHeight;

/* creates the waypoint position */
_wp =_grp addWaypoint [getmarkerpos _mkrname, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "NORMAL";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointCombatMode "BLUE";
_wp setWaypointCompletionRadius 50;

sleep 3;

/* dialog from pilot to player */
if (RUM_FXD_flightCheckIn) then {
	["flightcheckin",[player,_pilot,_callsign,_payload]] execVM (RUM_PATH+"Fxd\radiodialogs.sqf");
};

/* exits script */
if (true) exitwith {};

